package com.lin.genericstest;

import java.util.ArrayList;
import java.util.List;

/**
 * 泛型数组
 * 不能创建一个确切泛型类型的数组。如下面代码会出错 List<String>[] lsa = new ArrayList<String>[10];
 * @author Zhang
 *
 */
public class GenericsArrayDemo {
	public static void main(String[] args) {
		List<?>[] lsa = new List<?>[10];
		Object o = lsa;
		Object[] oa = (Object[]) o;
		List<Integer> li = new ArrayList<Integer>();
		li.add(1);
		oa[0] = li;
		List<String> ls = new ArrayList<String>();
		ls.add("hello");
		oa[1] = ls;
		//String s = (String) lsa[0].get(0);
		String s = (String) lsa[1].get(0);
		Integer i = (Integer) lsa[0].get(0);
		System.out.println("String:"+s+" Integer："+i);
	}
}
